<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableCarts extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('carts', function (Blueprint $table) {
            $table->increments('id')->comment('购物编号');
            $table->unsignedInteger('atime')->default('0')->omment('购物时间');
            $table->unsignedInteger('product_id')->default('0')->omment('产品编号');
            $table->unsignedInteger('user_id')->default('0')->omment('用户编号');
            $table->unsignedSmallInteger('pnum')->default('1')->comment('购买数量');
            $table->timestamps();

            $table->foreign('product_id')->references('id')->on('product');
            $table->foreign('user_id')->references('id')->on('user');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('carts');
    }
}
